package educar.inscripcion;

import java.awt.event.ActionListener;

import javax.swing.JOptionPane;
import javax.swing.JTable;
/**
 *
 * @author agu
 */

/**
*
* @author Ruano Mariano
*/
public class InscripcionMateriaVentana extends javax.swing.JFrame {

   /** Creates new form InscripcionMateriaVentana */
   public InscripcionMateriaVentana() {
       initComponents();
   }

   /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    */
   @SuppressWarnings("unchecked")
   // <editor-fold defaultstate="collapsed" desc="Generated Code">
   private void initComponents() {

       scroll = new java.awt.ScrollPane();
       jLabel1 = new javax.swing.JLabel();
       jLabel2 = new javax.swing.JLabel();
       materia = new javax.swing.JTextField();
       dni = new javax.swing.JTextField();
       inscribir = new javax.swing.JButton();
       cancelar = new javax.swing.JButton();
       scroll1 = new javax.swing.JScrollPane();

       setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
       setTitle("Inscribir materia");

       jLabel1.setText("Codigo de materia:");

       jLabel2.setText("DNI Alumno:");

       inscribir.setText("Inscribir");

       cancelar.setText("Cancelar");
       cancelar.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               cancelarActionPerformed(evt);
           }
       });

       javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
       getContentPane().setLayout(layout);
       layout.setHorizontalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(layout.createSequentialGroup()
               .addContainerGap()
               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addGroup(layout.createSequentialGroup()
                       .addComponent(scroll, javax.swing.GroupLayout.DEFAULT_SIZE, 558, Short.MAX_VALUE)
                       .addContainerGap())
                   .addGroup(layout.createSequentialGroup()
                       .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                           .addGroup(layout.createSequentialGroup()
                               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                   .addComponent(jLabel2)
                                   .addComponent(jLabel1))
                               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                   .addComponent(dni)
                                   .addComponent(materia, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE))
                               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 121, Short.MAX_VALUE))
                           .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                               .addComponent(inscribir)
                               .addGap(141, 141, 141)))
                       .addComponent(cancelar)
                       .addGap(130, 130, 130))))
       );
       layout.setVerticalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(layout.createSequentialGroup()
               .addContainerGap()
               .addComponent(scroll, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addGap(22, 22, 22)
               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                   .addComponent(jLabel1)
                   .addComponent(materia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
               .addGap(18, 18, 18)
               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                   .addComponent(dni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                   .addComponent(jLabel2))
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                   .addComponent(cancelar)
                   .addComponent(inscribir, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
               .addGap(25, 25, 25))
       );

       pack();
   }// </editor-fold>

private void cancelarActionPerformed(java.awt.event.ActionEvent evt) {
//TODO add your handling code here:
}

   /**
    * @param args the command line arguments
    */
   public static void main(String args[]) {
       /* Set the Nimbus look and feel */
       //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
       /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
        * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
        */
       try {
           for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
               if ("Nimbus".equals(info.getName())) {
                   javax.swing.UIManager.setLookAndFeel(info.getClassName());
                   break;
               }
           }
       } catch (ClassNotFoundException ex) {
           java.util.logging.Logger.getLogger(InscripcionMateriaVentana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       } catch (InstantiationException ex) {
           java.util.logging.Logger.getLogger(InscripcionMateriaVentana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       } catch (IllegalAccessException ex) {
           java.util.logging.Logger.getLogger(InscripcionMateriaVentana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       } catch (javax.swing.UnsupportedLookAndFeelException ex) {
           java.util.logging.Logger.getLogger(InscripcionMateriaVentana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       }
       //</editor-fold>

       /* Create and display the form */
       java.awt.EventQueue.invokeLater(new Runnable() {

           public void run() {
               new InscripcionMateriaVentana().setVisible(true);
           }
       });
   }
   // Variables declaration - do not modify
   private javax.swing.JButton cancelar;
   private javax.swing.JTextField dni;
   private javax.swing.JButton inscribir;
   private javax.swing.JLabel jLabel1;
   private javax.swing.JLabel jLabel2;
   private javax.swing.JTextField materia;
   private java.awt.ScrollPane scroll;
   private javax.swing.JScrollPane scroll1;
   // End of variables declaration
   
   	public String getCodMat(){
    	return materia.getText().trim();
	}
    
    public String getDni(){
    	return dni.getText().trim();
	}
    public void limpiar (){
    	materia.setText("");
		dni.setText("");
    }
	
	public void setTable (JTable tabla){
    	scroll1.setViewportView(tabla); 
    	scroll.add(scroll1);
    }
	 
    public void addActionListener(ActionListener lis){
	   	cancelar.addActionListener(lis);
	   	inscribir.addActionListener(lis);
	}
}



